home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / hplip / ui4 / nodevicesdialog.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2009-04-20  |  2.8 KB  |  63 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. from base.g import *
  5. from base import device, utils
  6. from ui_utils import *
  7. from PyQt4.QtCore import *
  8. from PyQt4.QtGui import *
  9. from nodevicesdialog_base import Ui_NoDevicesDialog_base
  10.  
  11. class NoDevicesDialog(QDialog, Ui_NoDevicesDialog_base):
  12.     
  13.     def __init__(self, parent):
  14.         QDialog.__init__(self, parent)
  15.         self.setupUi(self)
  16.         self.initUi()
  17.  
  18.     
  19.     def initUi(self):
  20.         self.connect(self.SetupButton, SIGNAL('clicked()'), self.SetupButton_clicked)
  21.         self.connect(self.CUPSButton, SIGNAL('clicked()'), self.CUPSButton_clicked)
  22.         self.connect(self.CloseButton, SIGNAL('clicked()'), self.CloseButton_clicked)
  23.         self.Icon.setPixmap(load_pixmap('warning', '32x32'))
  24.  
  25.     
  26.     def SetupButton_clicked(self):
  27.         self.close()
  28.         su_sudo = None
  29.         if utils.which('kdesu'):
  30.             su_sudo = 'kdesu -- %s'
  31.         elif utils.which('kdesudo'):
  32.             su_sudo = 'kdesudo -- %s'
  33.         elif utils.which('gnomesu'):
  34.             su_sudo = 'gnomesu -c "%s"'
  35.         elif utils.which('gksu'):
  36.             su_sudo = 'gksu "%s"'
  37.         
  38.         if su_sudo is None:
  39.             QMessageBox.critical(self, self.windowTitle(), self._NoDevicesDialog__tr('<b>Unable to find an appropriate su/sudo utility to run hp-setup.</b>'), QMessageBox.Ok, QMessageBox.NoButton, QMessageBox.NoButton)
  40.         elif utils.which('hp-setup'):
  41.             cmd = su_sudo % 'hp-setup -u'
  42.         else:
  43.             cmd = su_sudo % 'python ./setup.py -u'
  44.         log.debug(cmd)
  45.         utils.run(cmd, log_output = True, password_func = None, timeout = 1)
  46.         
  47.         try:
  48.             self.parent().rescanDevices()
  49.         except Error:
  50.             QMessageBox.critical(self, self.windowTitle(), self._NoDevicesDialog__tr('<b>An error occurred.</b><p>Please re-start the Device Manager and try again.'), QMessageBox.Ok, QMessageBox.NoButton, QMessageBox.NoButton)
  51.  
  52.  
  53.     
  54.     def CUPSButton_clicked(self):
  55.         self.close()
  56.         utils.openURL('http://localhost:631/admin?op=add-printer')
  57.  
  58.     
  59.     def CloseButton_clicked(self):
  60.         self.close()
  61.  
  62.  
  63.